#include <stdio.h>
#include <assert.h>

#include "library.h"

void test_pool_creation() {
    printf("Testing pool creation...\n");
    FixedPoolInterface* pool = create_fixed_pool(10, sizeof(int));
    assert(pool != NULL);
    assert(pool->pool_unused_size == 10);
    printf("Pool creation test passed!\n");
    
    release_fixed_pool(pool);
}

void test_item_allocation() {
    printf("Testing item allocation...\n");
    FixedPoolInterface* pool = create_fixed_pool(5, sizeof(int));

    int* item = (int*)get_item_in_pool(pool);
    assert(item != NULL);
    assert(pool->pool_unused_size == 4);
    
    *item = 42;
    assert(*item == 42);
    printf("Item allocation test passed!\n");
    
    put_item_in_pool(pool, (PItemData)item);
    assert(pool->pool_unused_size == 5);
    release_fixed_pool(pool);
}

int main() {
    test_pool_creation();
    test_item_allocation();
    printf("All tests passed!\n");
    return 0;
}